﻿using Service.Auth.Model.Enum;
using Service.Framework.Utils.Extension;

namespace Service.Auth.Model.Model.Dto;

public class UserInfoDto
{
    public long Id { get; set; }
    public string Account { get; set; }

    public string RealName { get; set; }

    private string Phone { get; set; }

    public string PhoneText
    {
        get
        {
            if (string.IsNullOrWhiteSpace(Phone) || Phone.Length < 4)
                return Phone;
            return $"***{Phone.Substring(Phone.Length - 4)}";
        }
    }

    private List<UserSystemRoleDto> UserSystemRoles { get; set; }
    public List<string> Roles
    {
        get
        {
            return UserSystemRoles?.Select(s => s.RoleNum).ToList();
        }
    }

    public List<IdName<long, string>> Systems
    {
        get
        {
            return UserSystemRoles?.GroupBy(s => s.SystemId).Select(s => new IdName<long, string>(s.Key, s.FirstOrDefault().SystemName)).ToList();
        }
    }


    public DateTime CreateTime { get; set; }


    public string Picture { get;  set; }



    public UsetStatusEnum Status { get; set; }

    public string StatusText => 
        Status.ToDescription();
}